﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.system.basis
{
    public partial class value : System.Web.UI.Page
    {
        Maticsoft.BLL.valuetype bll = new Maticsoft.BLL.valuetype();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //this.typelist.DataSource = typebll.GetAllList();
                //this.typelist.DataTextField = "typename";
                //this.typelist.DataValueField = "id";
                //this.typelist.DataBind();
                //this.typelist.Items.Insert(0, new ListItem("--请选择所属分类--", ""));
                //this.parentlist.DataSource = bll.GetList("parentcode=0");
                //this.parentlist.DataTextField = "name";
                //this.parentlist.DataValueField = "code";
                //this.parentlist.DataBind();
                //this.parentlist.Items.Insert(0, new ListItem("--请选择上级属性--", "0"));
                int totalOrders = bll.GetRecordCount("");
                AspNetPager1.RecordCount = totalOrders;

            }
        }
        void bindData(string where)
        {
            Repeater1.DataSource = bll.GetListByPage(where, "", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData(hidwhere.Value);
        }
        protected string getparentname(string parentid)
        {
            if ("0" == parentid)
                return "----";
            else
                return bll.GetModelList("code='" + parentid + "'")[0].name;
        }

        protected void btnserach_Click(object sender, EventArgs e)
        {
            string where = "id<>0 ";
            if (ddlisttype.SelectedItem.Value != "")
            {
                where += " and vtype = '" + ddlisttype.SelectedItem.Value + "'";
            }
            //if (parentlist.SelectedItem.Value != "0")
            //{
            //    where += " and parentcode = " + parentlist.SelectedItem.Value;
            //}
            if (name.Value != null && !string.IsNullOrEmpty(name.Value))
            {
                where += " and name like '%" + name.Value + "%'";
            }
            hidwhere.Value = where;
            bindData(hidwhere.Value);
        }
    }
}